package com.iszhangsc.backup.param.serialize;

import cn.hutool.core.io.FileUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * <p>
 * 可读的文件大小返回
 * </p>
 *
 * @author zhāngshìchāng
 * @date 2020/12/19 5:29 下午
 */
public class ReadableFileSizeSerialize extends JsonSerializer<Long> {


    @Override
    public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString(FileUtil.readableFileSize(value));
    }

}
